<?php
my_component_load('testing' , false);
my_component_load('paging' , false); 
my_component_load('xl_builder' , false); 
my_component_load('list_kalender' , false); 
my_component_load('spl');
$task = isset($_GET['task']) ? $_GET['task'] : ""; 
$id = isset( $_GET['id'] ) ? $_GET['id']:  0;
$spl_id = isset( $_GET['spl_id'] ) ? $_GET['spl_id']:  0;
$modulname = "Personalia _BN_ Waktu Kerja _BN_ Lembur";

if($_SERVER['REQUEST_METHOD'] =="POST"){
	switch($task){ 
		case "edit_page":
			$validate = spl_validate( $id );
			if($validate ){
				$pagename = ($id>0)? $modulname." _BN_ Perubahan Data" : $modulname." _BN_ Tambah Data";
				$content = message_multi_error($validate); 
				$content .=form_spl_create($id); 
				generate_my_web($content, $pagename ,"plain.php");
				exit;
			}else{
				spl_submit($id );
				if($_POST['create_other']){
					//$content = form_spl_create($id); 
					//generate_my_web($content, $pagename ,"plain.php");
					my_direct("index.php?com=".$_GET['com']."&task=edit_page&pdate=".$_POST['tanggal']);
					exit;
				}else{
					generate_my_web("Updated!!", '','plain.php');
					exit;
					
				}
			}
			break;
	}
}else{
	switch($task){ 
	
	

		case "excel_lembur":
			header("Content-Type: application/xls");
			header("Content-Disposition: attachment;filename=lembur_export.xls");
			echo spl_excel();
			exit;
			break;
		case "spl_kalkulasi":
			spl_kalkulasi();
			my_direct($_SERVER['HTTP_REFERER']);
			break;	
		case "list_koreksi":
			$pagename 	= $modulname." _BN_ Koreksi History";
			load_facebox_script();	
			$content 	=  list_koreksi($spl_id);	
			break;
		case "delete_koreksi":
			delete_koreksi($id);
			my_direct($_SERVER['HTTP_REFERER']);
			break;

		case "restore":
			restore_spl($id);
			my_direct($_SERVER['HTTP_REFERER']);
			break;
		case "delete":
			delete_spl($id);
			my_direct($_SERVER['HTTP_REFERER']);
			break;
		case "edit":
			facebox_page( 'index.php?com='.$_GET['com'].'&task=edit_page&id='.$_GET['id'], ($id >0 ? "Ubah Data ": "Tambah Data"),450);
			break;
		case "edit_page":
			$pagename = ($id>0)? $modulname." _BN_ Perubahan Data" : $modulname." _BN_ Tambah Data";
			$content =form_spl_create($id); 
			generate_my_web($content, $pagename ,"plain.php");
			exit;
			break;
		default:
			$pagename 	= $modulname;
			load_facebox_script();	
			$content 	=  list_spl();
		break;
	}
}

generate_my_web($content, $pagename  );